﻿using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;

namespace News.WebParts.CuoiMimChiBanCoBietWebPart
{
    [ToolboxItemAttribute(false)]
    public class CuoiMimChiBanCoBietWebPart : WebPart
    {
        // Visual Studio might automatically update this path when you change the Visual Web Part project item.
        private const string _ascxPath = @"~/_CONTROLTEMPLATES/News.WebParts/CuoiMimChiBanCoBietWebPart/CuoiMimChiBanCoBietWebPartUserControl.ascx";

        protected override void CreateChildControls()
        {
            Control control = Page.LoadControl(_ascxPath);
            var userControl = control as CuoiMimChiBanCoBietWebPartUserControl;
            if (userControl != null) userControl.NewsCategory = NewsCategory;
            if (userControl != null) userControl.RowLimit = RowLimit;
            Controls.Add(control);
        }

        public string _newsCategory;
        [Category("Settings"),
        Personalizable(PersonalizationScope.Shared),
        WebBrowsable(true),
        WebDisplayName("Category"),
        WebDescription("Category of News")]
        public string NewsCategory
        {
            get { return _newsCategory; }
            set { _newsCategory = value; }
        }


        public int _rowLimit;
        [Category("Settings"),
        Personalizable(PersonalizationScope.Shared),
        WebBrowsable(true),
        WebDisplayName("Row Limit"),
        WebDescription("Row Limit")]
        public int RowLimit
        {
            get { return _rowLimit; }
            set { _rowLimit = value; }
        }
    }
}
